import {createApi} from '@reduxjs/toolkit/dist/query/react'
import axiosBaseQuery from '../ utils/axiosBaseQuery'

const searchSliceApi = createApi({
    reducerPath:'musicListApi',
    baseQuery:axiosBaseQuery({
        baseUrl:'http://localhost:3001/'
    }),
    endpoints(build) {
        return{
            getSearchList:build.query({
                query(keywords) {
                    return{
                        url:`search?keywords=${keywords}`,
                        method:'get',
                    }
                }
            }),
            getDefaultList:build.query({
                query(arg) {
                    return{
                        url:'search/hot/detail',
                        method:'get'
                    }
                }
            })
        }
    }
})
export const {useGetSearchListQuery,useGetDefaultListQuery} = searchSliceApi
export default searchSliceApi